#include<iostream>
#include <string>
using namespace std;

void byteone(){
	
	int n;
	cin >> n;
	cin.sync();
	char **res = new char*[n];
	for (int k = 0; k < n; k++){
		string str;
		cin >> str;
		int length = str.length();
		int one = 1, two = 0;
		for (int i = 1; i < length; i++){
			if (str[i - 1] == str[i]){
				one++;
			}
			else if (one == 2 && str[i - 1] == str[i]){
				two++;
			}
			else if (two == 0 && str[i - 1] != str[i]) {
				one = 0;
			}
			if (one == 3 || two == 2){
				int j = i;
				while (j < length-1){
					str[j] = str[j + 1];
					j++;
				}
				length--;
				i--;
				if (one == 3) {
					one--;
				}
				if (two == 2) {
					two--;
				}
				
			}

		}
		
		res[k] = new char[length];
		for (int m = 0; m < length; m++){
			res[k][m] = str[m];
		}
		cin.sync();
	}

	for (int k = 0; k < n; k++){
		cout << res[k] << endl;
	}


	cin.get();
}